<template>
	<view>
		<!-- <van-popup :show="showVersion" bind:close="onClose"
			custom-style="padding:30rpx 30rpx 20rpx 30rpx;border-radius:12rpx;font-size:26rpx;width:76%;" :round="true"
			@close="closeVersion" :close-on-click-overlay="true">
			<view class="" style="text-align: center;">
				新版本已上线，请重新启动小程序使用新版本
			</view>
			<view class="restart" @click="restart">
				重启小程序
			</view>
		</van-popup> -->
	</view>
</template>

<script>
	import http from './utils/http';
	export default {
		data() {
			return {
				showVersion: false,
			};
		},
		globalData: {
			navTop: '',
			Login: function() {
				let that = this;
				uni.login({
					complete: (res) => {
						let data = {
							code: res.code
						};
						let h = {
							'content-type': 'application/x-www-form-urlencoded'
						};
						uni.request({
							url: http.appUrl + 'login/getLogin',
							data: data,
							method: 'POST',
							header: h,
							success: (res) => {
								uni.setStorageSync('token', res.data.data.token.token);
								uni.setStorageSync('is_login', res.data.code);
							},
							fail: function(res) {
								console.log(res);
							}
						});
					}
				});
			}
		},
		onLaunch(options) {
			this.removeUserLocation()
			uni.setStorageSync('scene', options.scene);
			let menuButtonObject = uni.getMenuButtonBoundingClientRect();
			uni.getSystemInfo({
				success: (res) => {
					let statusBarHeight = res.statusBarHeight;
					let navTop = menuButtonObject.top;
					let //胶囊按钮与顶部的距离
						navHeight = statusBarHeight + menuButtonObject.height + (menuButtonObject.top -
							statusBarHeight) * 2; //导航高度
					this.globalData.navHeight = navHeight;
					this.globalData.navTop = navTop;
					this.globalData.windowHeight = res.windowHeight;
					this.globalData.screenScale = res.screenWidth / 375;
					this.globalData.systemInfo = res;
				},
				fail(err) {
					console.log(err);
				}

			});
			const updateManager = uni.getUpdateManager();
			updateManager.onUpdateReady(function() {
				updateManager.applyUpdate()
			})
		},
		methods: {
			removeUserLocation() {
				const latitude = uni.getStorageSync('latitude')
				const longitude = uni.getStorageSync('longitude')
				const address_component = uni.getStorageSync('address_component')
				if (latitude) {
					uni.removeStorageSync('latitude')
				}
				if (longitude) {
					uni.removeStorageSync('longitude')
				}
				if (address_component) {
					uni.removeStorageSync('address_component')
				}
				// uni.getLocation({
				//     isHighAccuracy: true,  
				//     type: 'gcj02',  
				//     success(rest) {  
				//         const { latitude, longitude } = rest;  
				//         that.my_longitude = longitude;  
				//         that.my_latitude = latitude;  
				//         uni.setStorageSync('latitude', latitude);  
				//         uni.setStorageSync('longitude', longitude);  

				//         // 如果地址组件已存在  
				//         if (uni.getStorageSync('address_component')) {  
				//             const address_component = JSON.parse(uni.getStorageSync('address_component'));  
				//             requestSettledList(latitude, longitude, address_component);  
				//         } else {  
				//             // 如果不存在，则请求地址组件  
				//             uni.request({  
				//                 url: "https://apis.map.qq.com/ws/geocoder/v1/",  
				//                 data: {  
				//                     key: "XUDBZ-3OVAL-KWEPB-MXU6W-KW4XK-6WBHF",  
				//                     location: `${latitude},${longitude}`  
				//                 },  
				//                 success(result) {  
				//                     const data = result.data.result.address_component;  
				//                     uni.setStorageSync('address_component', JSON.stringify(data));  
				//                     requestSettledList(latitude, longitude, data);  
				//                 },  
				//                 fail(err) {  
				//                     console.error('Error fetching address component:', err);  
				//                 }  
				//             });
				//         }  
				//     },  
				//     fail(err) {
				// 		that.isAuth_location = false
				//         console.error('Failed to get location:', err);  
				//     }  
				// });  
			},
			closeVersion() {
				this.showVersion = false
			},
			restart() {

			}
		},
	};
</script>
<style>
	@import './app.css';

	.my button {
		height: 94rpx;
		border: none !important;
		display: flex;
		justify-content: space-between;
		flex-direction: column;
		align-items: center;
		line-height: 32rpx;
		padding: 0;
		outline: none;
		box-shadow: none;
		-webkit-tap-highlight-color: transparent;
	}

	.my button::after {
		display: none;
	}

	button::after {
		display: none;
	}

	.agreementBox {
		display: flex;
		align-items: center;
		justify-content: center;
		margin-top: 30rpx;
	}

	.quotationNum {
		font-size: 24rpx;
		color: #1050c7;
		font-weight: bold;
		width: 144rpx;
		padding-bottom: 11.33rpx;
		text-align: center;
		line-height: 1;
	}
</style>